//
//  RBDaylySignDateCell.m
//  zhongzhenglu
//
//  Created by XL on 2022/8/30.
//

#import "RBDaylySignDateCell.h"
#import "FSCalendar.h"
#import "FSCalendarExtensions.h"
#import "FSCalendarDynamicHeader.h"
#import "FSCalendarConstants.h"
#import <UIView+YYAdd.h>
#import "UIView+RBAdd.h"
#import "RBDefine.h"
#import <Masonry.h>
#import <UIColor+YYAdd.h>
#import "RBThemeConfig.h"

@interface RBDaylySignDateCell()

@property(nonatomic, strong)UILabel *displayTitleL;
@property(nonatomic, strong)UIView *dotBgView;
@property(nonatomic, strong)UIImageView *dotImgView;

@end

@implementation RBDaylySignDateCell

#pragma mark - Setter

- (void)setSign:(BOOL)sign
{
    _sign = sign;
    [self.dotBgView.superview sendSubviewToBack:self.dotBgView];
    self.titleLabel.hidden = YES;
    self.displayTitleL.text = self.day;
    self.displayTitleL.font = [UIFont systemFontOfSize:12];
    if (self.inMonth)
    {
        if (sign)
        {
            self.displayTitleL.textColor = UIColor.whiteColor;
            self.dotBgView.hidden = NO;
            self.dotImgView.hidden = NO;
        }
        else
        {
            self.displayTitleL.textColor = [RBThemeConfig textBlackColor];
            self.dotBgView.hidden = YES;
            self.dotImgView.hidden = YES;
        }
    }
    else
    {
        self.displayTitleL.textColor = [RBThemeConfig textGrayColor];
        self.dotBgView.hidden = YES;
        self.dotImgView.hidden = YES;
    }
}

#pragma mark - Getter

- (UILabel *)displayTitleL
{
    if (!_displayTitleL)
    {
        self.displayTitleL = ({
            UILabel *view = UILabel.new;
            [self.titleLabel.superview addSubview:view];
            [view mas_makeConstraints:^(MASConstraintMaker *make) {
                make.center.mas_equalTo(self.titleLabel);
            }];
            view;
        });
    }
    return _displayTitleL;
}

- (UIView *)dotBgView
{
    if (!_dotBgView)
    {
        self.dotBgView = ({
            UIView *view = UIView.new;
            view.backgroundColor = [UIColor colorWithHexString:@"#4581FF"];
            [view rbSetCornerRadius:10.5];
            [self.titleLabel.superview addSubview:view];
            [view mas_makeConstraints:^(MASConstraintMaker *make) {
                make.width.height.mas_equalTo(21);
                make.center.mas_equalTo(self.titleLabel);
            }];
            view;
        });
    }
    return _dotBgView;
}

- (UIImageView *)dotImgView
{
    if (!_dotImgView)
    {
        self.dotImgView = ({
            UIImageView *view = [RanTool imgViewWithMode:0 radius:0 imgName:@"signCheck"];
            [self.dotBgView.superview addSubview:view];
            [view mas_makeConstraints:^(MASConstraintMaker *make) {
                make.width.height.mas_equalTo(7);
                make.centerX.mas_equalTo(self.dotBgView);
                make.top.mas_equalTo(self.dotBgView.mas_bottom).offset(7);
            }];
            view;
        });
    }
    return _dotImgView;
}

@end
